package BZimmerman.AndroidWars;

import java.util.Random;

import android.graphics.PointF;

public class populateMap {
	private castleActions[][] palaceMap;
	populateMap(int[][] map,int tiles){
		palaceMap = new castleActions[tiles][tiles];
		for(int y = 0; y < tiles; y++){
			for(int x = 0; x< tiles; x++){
				palaceMap[x][y] = new castleActions(new PointF(x,y),0);
			}
		}
		setCastles(map,tiles,10);
	}
	public void setCastles(int[][] map, int size, int castles){
		Random random = new Random(System.currentTimeMillis());
		PointF select = new PointF(0,0);
		for(int i = 0; i < castles; i++){
			System.out.println("Lake: "+ 1);
			select.x = random.nextInt( size-2 );
			select.y = random.nextInt( size-2 );
			while (map[(int) (select.x+1)][(int) (select.y+1)] == 0){
				select.x = random.nextInt( size-2 );
				select.y = random.nextInt( size-2 );
			}
			select.x+=1;
			select.y+=1;
			palaceMap[(int) select.x][(int) select.y].setCastle(1);
		}
	}
	public castleActions returnCastleLocation(PointF Location){
		return palaceMap[(int) Location.x][(int) Location.y];
	}
}
